package com.aaa.marketing.controller.api;/**
 * Date:2023/3/2
 * Author：臣哥哥
 * Description:
 */

import com.aaa.entity.Advertise;
import com.aaa.entity.Company;
import com.aaa.marketing.service.CompanyService;
import com.aaa.security.annotation.HasPermission;
import com.aaa.security.annotation.MyLog;
import com.aaa.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author     ：Xiaochen
 * @date       ：Created in 2023/3/2 12:17
 * @description：
 * @modified By：
 * @version:
 */
@Api(value = "marketing/api/company", tags = {"合作公司控制"})
@RestController
@RequestMapping("marketing/api/company")
public class ApiCompanyController {
    @Autowired
    private CompanyService companyService;

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true),
            @ApiImplicitParam(paramType = "body", dataType = "Company", name = "company", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "")
    @HasPermission(value = "company:search")
    @MyLog(title = "查询所有合作公司")
    @RequestMapping("select")
    @ResponseBody
    public Result list(@RequestParam(defaultValue = "1") Integer currentPage, @RequestParam(defaultValue = "5") Integer pageSize, @RequestBody Company company){
        return companyService.selectAll(currentPage,pageSize,company);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Company", name = "company", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @HasPermission(value = "company:insert")
    @MyLog(title = "添加合作公司")
    @PostMapping("insert")
    public Result insert(@RequestBody Company company){
        return companyService.insert(company);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Company", name = "company", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @HasPermission(value = "company:update")
    @MyLog(title = "修改合作公司")
    @PostMapping("update")
    public Result update(@RequestBody Company company){
        return companyService.update(company);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "id", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @HasPermission(value = "company:delete")
    @MyLog(title = "删除合作公司")
    @GetMapping("delete")
    public Result delete(Integer id){
        return companyService.delete(id);
    }
}